"use strict";

Object.defineProperty(exports, "__esModule", {
    value: true
});
var getFitSize = exports.getFitSize = function getFitSize(origin, target) {
    var width = origin.width,
        height = origin.height;

    var radio = getRatio(origin, target);

    return {
        radio: radio,
        width: width * radio,
        height: height * radio
    };
};
var getRatio = exports.getRatio = function getRatio(origin) {
    var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    var width = origin.width,
        height = origin.height;

    var tWidth = target.width;
    var tHeight = target.height;

    if (tWidth && !tHeight) {
        return tWidth / width;
    }
    if (!tWidth && tHeight) {
        return tHeight / height;
    }
    if (tWidth && tHeight) {
        return Math.min(tWidth / width, tHeight / height);
    }
    return 1;
};
exports.default = getFitSize;